<?php 
/** Load header
*/
$this->load->view('header', $template) ;
?>
<link href='http://fonts.googleapis.com/css?family=Allura' rel='stylesheet' type='text/css'>
<!-- <link rel="stylesheet" href="<?php //echo base_url() ?>assets/css/home.css"> -->

<link rel="stylesheet" href="<?php echo base_url() ?>assets/css/formpage.css">
<!-- ---------------------------------------------------------- -->
	<section class="title">
		<div class="wrapper">
			<h2 class='title'>
				Chỉnh sửa tài liệu
			</h2>
		</div>
	</section>	

	<section>
		<div class="wrapper form-visible">
			<form enctype="multipart/form-data" action="<?php echo base_url() ?>book/update_info_book/<?php echo $info['id_document'] ?> " method="post">
				<p>
					<label>Tên sách:</label> 
					<input type="text" name="title" value="<?php echo $info['name_document']; ?>" > 
				</p>				
				<p>
					<label>Tác giả:</label> 
					<input type="text" name="author" value="<?php echo $info['author']; ?>"> 
				</p>
				<p>
					<label>Mô tả:</label>
					<textarea name="description"><?php echo $info['description']; ?></textarea>
				</p>
				<p>
					<label>Lĩnh vực:</label>
					<input class="list" list="cat" name="category" value="<?php echo $info['category']; ?>" >
					<datalist id="cat">
						<?php foreach($cat as $c) {
							echo '<option value="'.$c->id_cat.'">'.$c->name_cat.'</option>';
						}  ?>
					</datalist> 
				</p>
				<p>
					<label>Tags:</label>
					<input type="text" name="tags" value="<?php echo $info['tags']; ?>"> 
				</p>
				<p>
					<label>Vị trí liên quan:</label>
					<span class="old" style="float:right;font-size:10pt;color:#999">
						Vị trí cũ: <?php echo $info['type_location'].' '.$info['name_location'] ?>
					</span>
					<span class="location">
						<select name="location">
							<option value="<?php echo $info['location'] ?>">Như cũ</option>
							<option value="00">Bỏ chọn</option>
							<?php foreach($loca as $lo) {
								echo '<option value="'.$lo->id_location.'">'
								.$lo->type_location.' '.$lo->name_location.'</option>';
							}  ?>
						</select>
					</span>

					<!-- <input class="list" list="loca" name="location" value="<?php //echo $info['location'] ?>">
					<datalist id="loca">
						<?php foreach($loca as $lo) {
							//echo '<option value="'.$lo->id_location.'">'.$lo->name_location.'</option>';
						}  ?>
					</datalist> -->
				</p>
				<p>
					<input type="submit" name="update" value="Update" placeholder="">
				</p>
			</form>

		</div>
	</section>

<!-- ---------------------------------------------------------- -->
<script>
	$('span.location select').change(function(){
		// alert(this.value);
		$('span.location .child').remove();
		if(this.value != 'null') {
			$.ajax({
				type: "POST",
				url: '/openlibraryonline/book/ajax_child_location/',
				data: ({
					parent: this.value
				}),
				success: function(data) {
					if(data != '')
						$('span.location').append(data);
				}
			});
		}
	});
</script>
<?php
/** Load Footer
*/
$this->load->view('footer') ;
?>